package libs

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/httplib"
)

func GetPoi(address string) (string, error) {
	tag := "公司企业,政府机构,房地产"
	city := "温州市"
	ak := "6vCl7GxL10LvnvGbfDpDDST4fBb91Ayd"
	scope := "1" //检索结果详细程度。取值为1 或空，则返回基本信息；取值为2，返回检索POI详细信息
	url := "http://api.map.baidu.com/place/v2/search?query=" + address + "&tag=" + tag + "&region=" + city + "&output=json&ak=" + ak + "&city_limit=false&scope=" + scope
	req := httplib.Get(url)
	str, err := req.String()
	return str, err
}

func Geocoder(address string) (string, error) {
	ak := "6vCl7GxL10LvnvGbfDpDDST4fBb91Ayd"
	url := "http://api.map.baidu.com/geocoder/v2/?address=" + address + "&output=json&ak=" + ak
	req := httplib.Get(url)
	str, err := req.String()
	if err != nil {
		beego.Error("获取地理编码:", err)
		str = "获取地址编码失败"
	}
	return str, err
}
